Modes VariableThe m g
(calc-get-modes) command pushes onto the stack a
vector of numbers that describes the various mode settings that
are in effect. With a numeric prefix argument, it pushes only the
nth mode, i.e., the nth element of this
vector. Keyboard macros can use the m g command to
modify their behavior based on the current mode settings.
The modes vector is
also available in the special variable Modes. In
other words, m g is like s r Modes
<RET>. It will not work to store into this variable;
in fact, if you do, Modes will cease to track the
current modes. (The m g command will continue to work,
however.)
In general, each number in this vector is suitable as a numeric prefix argument to the associated mode-setting command. (Recall that the ~ key takes a number from the stack and gives it as a numeric prefix to the next command.)
The elements of the modes vector are as follows:
For example, the sequence M-1 m g <RET> 2 + ~ p increases the precision by two, leaving a copy of the old precision on the stack. Later, ~ p will restore the original precision using that stack value. (This sequence might be especially useful inside a keyboard macro.)
As another example, M-3 m g 1 - ~ <DEL> deletes all but the oldest (bottommost) stack entry.
Yet another example: The HP-48 “round” command rounds a number to the current displayed precision. You could roughly emulate this in Calc with the sequence M-5 m g 10000 % ~ c c. (This would not work for fixed-point mode, but it wouldn't be hard to do a full emulation with the help of the Z [ and Z ] programming commands. See Conditionals in Macros.)